package scalaLearning.part5

class Person() {
  def eat() = {
    println("Person eat")
  }
}

class Student() extends Person {
  override def eat() = {
    println("Student eat")
  }
}

class ChildStudent() extends Student {
  override def eat() = {
    println("ChildStudent eat")
  }
}


object GenericBound {
  def getClassName[A >: Student](p: A) = {
    println(p.toString)
  }

  def main(args: Array[String]): Unit = {
    getClassName[Person](new Person)
    getClassName[Student](new Student)
    //报异常
    //getClassName[ChildStudent](new ChildStudent)
  }
}

